package team.seekers.hula.course.resource.exam.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import team.seekers.hula.common.annotation.ApiResponseBody;
import team.seekers.hula.course.resource.exam.entity.dto.ExamQueryDTO;
import team.seekers.hula.course.resource.exam.entity.vo.ExamProblemListVO;
import team.seekers.hula.course.resource.exam.service.ExamService;

import javax.validation.constraints.NotBlank;
import java.util.List;

@Controller
@ApiResponseBody
@RequestMapping("/exam")
public class ExamController {

    @Autowired
    private ExamService examService;

    /**
     * 查询测试详细信息
     * @param examIds 测试id集合
     */
    @GetMapping("/queryByIds")
    public List<ExamQueryDTO> queryByIds(@RequestParam("examIds") @NotBlank List<Long> examIds) {
        return examService.queryByIds(examIds);
    }

//    /**
//     * 获取课程下所有测试集合
//     */
//    @GetMapping("/queryCourseExams")
//    @ResponseBody
//    public HashMap<String, Object> queryCourseExams(@RequestParam String courseId) {
//        List<List<ExamQueryDTO>> chapterExams = examService.listChapterExamByCourseId(courseId, MindUtils.getUserId());
//        List<ExamQueryDTO> finalExams = examService.listFinalExamByCourseId(courseId, MindUtils.getUserId());
//
//        HashMap<String, Object> result = new HashMap<>();
//        result.put("chapterExams",chapterExams);
//        result.put("finalExams",finalExams);
//        return result;
//    }

    /**
     * 获取测试的题目列表
     * @param examId 测试id
     */
    @GetMapping("/queryExamProblems")
    public List<ExamProblemListVO> queryExamProblems(@RequestParam String examId) {
        return examService.queryExamProblems(examId);
    }

}
